
#include "Scene2D/Engine.Scene2D.h"
#include "Graphics/Tests/Test.Application.h"

using namespace Scene2D;
using namespace Audio;

#undef  APP_NAME
#define APP_NAME	TestSceneApp
#undef  APP_BASE
#define APP_BASE	TestApp


class APP_NAME : public APP_BASE
{
protected:
	SceneManager	sceneMngr;
	AudioEngine		audioEngine;


public:
	APP_NAME (IPlatform *platform, EDevice::type deviceType) :
		APP_BASE( platform, deviceType ), sceneMngr( ESS() ),
		audioEngine( ESS() )
	{}


	void Update (float dt) override
	{
		TestApp::Update( dt );

		ESS()->GetGraphicsEngine()->GetViewport()->Apply();
		ESS()->GetGLStateManager()->ClearColor( color4f( 1.0f ) );
		
		sceneMngr.Update( dt );
		sceneMngr.Draw();

		batch.Flush();
		batch.Clear();
		
		ESS()->GetGraphicsEngine()->SwapBuffers();
	}


	void OnInit () override
	{
		APP_BASE::OnInit();
		
		audioEngine.Init();
		audioEngine.InitResources();
	}


	void OnEnter () override
	{
		APP_BASE::OnEnter();
	}


	void OnExit () override
	{
		sceneMngr.Destroy();
		APP_BASE::OnExit();
	}
};